﻿using System;
using WaitLess.Business.Data.Foursquare.Interfaces;
using WaitLess.Business.Data.Model.Foursquare.CheckinRequest;
using WaitLess.Business.Repositories.Interfaces;

namespace WaitLess.Business.Repositories
{
    public class CheckinRepository : ICheckinRepository
    {
        private readonly IFoursquareContext _fourSquareContext;

        public CheckinRepository(IFoursquareContext fourSquareContext)
        {
            if (fourSquareContext == null) throw new ArgumentNullException("fourSquareContext");

            _fourSquareContext = fourSquareContext;
        }

        public void Create(Request request, Action completedCallback)
        {
            if (request == null) throw new ArgumentNullException("request");
            if (string.IsNullOrWhiteSpace(request.AccessToken)) throw new ArgumentException("request.AccessToken", "request");
            if (string.IsNullOrWhiteSpace(request.VenueId)) throw new ArgumentException("request.VenueId", "request");
            if (string.IsNullOrWhiteSpace(request.Latitude)) throw new ArgumentException("request.Latitude", "request");
            if (string.IsNullOrWhiteSpace(request.Longitude)) throw new ArgumentException("request.Longitude", "request");
            if (completedCallback == null) throw new ArgumentNullException("completedCallback");
            
            _fourSquareContext.CheckIn(request, completedCallback);
        }
    }
}
